﻿using System;
using System.Collections.Generic;
using System.Reflection;

namespace Zinnia.Common.Core
{
    /// <summary>
    /// 提供类型信息的接口
    /// </summary>
    public interface ITypeService
    {
        /// <summary>
        /// 获取应用程序下所有程序集
        /// </summary>
        /// <returns>程序集集合</returns>
        IList<Assembly> GetAssemblies();
        /// <summary>
        /// 根据类型检索
        /// </summary>
        /// <param name="assignTypeFrom">搜索类型</param>
        /// <param name="onlyConcreteClasses">是否是具体类</param>
        /// <returns>查找到类型集合</returns>
        IEnumerable<Type> FindClassesOfType(Type assignTypeFrom, bool onlyConcreteClasses = true);
        /// <summary>
        /// 根据类型检索
        /// </summary>
        /// <param name="assignTypeFrom">搜索类型</param>
        /// <param name="assemblies">指定搜索程序集</param>
        /// <param name="onlyConcreteClasses">是否是具体类</param>
        /// <returns>查找到类型集合</returns>
        IEnumerable<Type> FindClassesOfType(Type assignTypeFrom, IEnumerable<Assembly> assemblies, bool onlyConcreteClasses = true);
        /// <summary>
        /// 在工程下检索类型
        /// </summary>
        /// <typeparam name="T">搜索类型</typeparam>
        /// <param name="onlyConcreteClasses">是否是具体类</param>
        /// <returns>查找到类型集合</returns>
        IEnumerable<Type> FindClassesOfType<T>(bool onlyConcreteClasses = true);
        /// <summary>
        /// 根据类型检索
        /// </summary>
        /// <typeparam name="T">搜索类型</typeparam>
        /// <param name="assemblies">指定搜索程序集</param>
        /// <param name="onlyConcreteClasses">是否是具体类</param>
        /// <returns>查找到类型集合</returns>
        IEnumerable<Type> FindClassesOfType<T>(IEnumerable<Assembly> assemblies, bool onlyConcreteClasses = true);
    }
}
